package com.wenlong.dao.impl;

import com.wenlong.dao.BashDao;
import com.wenlong.dao.UserDao;
import com.wenlong.pojo.User;

/**
 * @author 苏文龙
 * @version 1.0
 */
public class UserDaoImpl extends BashDao<User> implements UserDao {
    @Override
    public User queryUserByUsername(String username) {
        String sql = "select * from t_user where username = ?";
        return queryForOne(sql, User.class, username);
    }

    @Override
    public int saveUser(User user) {
        String sql = "insert into t_user(`username`, `password`, `email`) values(?,?,?)";
        return update(sql, user.getUsername(), user.getPassword(), user.getEmail());
    }

    @Override
    public User queryUserByUsernameAndPassword(String username, String password) {
        String sql = "select * from t_user where username = ? and password = ?";
        return queryForOne(sql, User.class, username, password);
    }
}
